//
//  HierarchicalObject.h
//  CocoaMoney
//
//  Created by Daniel Braun on 14/10/06.
//  Copyright 2006 Daniel Braun http://braun.daniel.free.fr. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@protocol HierarchicalObjectFiltering;

@interface HierarchicalObject : NSObject {
	NSMutableArray *children;
	id parent;
}

- (void)encodeWithCoder:(NSCoder *)coder;
- (id) initWithCoder:(NSCoder *) coder;

- (NSMutableArray *) children;
- (id) firstChild;
- (void) setChildren:(NSMutableArray *)a;
- (void) addChild:(id)c;
- (id) parent;
// setParent normally only invoked by addChild
// can be invoked to reparent object or remove it
- (void) setParent:(id)s;
- (BOOL) isLeaf;
- (int) count;
- (int) gCount;
- (int) level;
- (NSString *) indentString;
- (NSArray *) flatList;
- (NSArray *) flatListUsingFilter:(NSObject <HierarchicalObjectFiltering>*)filter;


- (id) recurseSelectorUntilNotil:(SEL) sel;
- (id) recurseSelectorUntilNotil:(SEL) sel  withObject:(id)arg;


- (void) recurseSelector:(SEL) sel;
- (void) recurseSelector:(SEL) sel withObject:(id)arg;
- (void) recurseSelector:(SEL) sel then:(SEL)sel2 withObject:(id)arg;


- (int) recurseIntAddSelector:(SEL) sel;
- (int) recurseIntAddSelector:(SEL) sel withObject:(id)arg;

- (double) recurseDoubleAddSelector:(SEL) sel;
- (double) recurseDoubleAddSelector:(SEL) sel includingSelf:(BOOL) doself;
- (double) recurseDoubleAddSelector:(SEL) sel withObject:(id)arg;

- (void) recurseSelector:(SEL) sel inArray:(NSMutableArray *)results;
- (void) recurseSelector:(SEL) sel withObject:(id)arg inArray:(NSMutableArray *)results;

- (BOOL) contains:(HierarchicalObject *)c;

- (void) checkParent;

@end
